package com.sharding.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sharding.demo.entity.Orders;
import com.sharding.demo.mapper.OrdersMapper;
import com.sharding.demo.service.OrdersService;
import com.sharding.demo.vo.OffocialDemoVo;
import com.sharding.demo.vo.OrdersVo;
import com.sharding.demo.vo.UserStaticsVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Classname OrderServiceImpl
 * @Description 用户服务实现类
 * @Author 章国文 13120739083@163.com
 * @Date 2019-06-28 17:32
 * @Version 1.0
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
    @Override
    public boolean save(Orders entity) {
        return super.save(entity);
    }

    @Override
    public IPage<Orders> selectPageVo(Page<Orders> page, Orders state, String orderBy, Boolean asc) {
        QueryWrapper<Orders> lambdaQueryWrapper = new QueryWrapper<>();

        if(StringUtils.isNoneBlank(orderBy)){
            if(asc){
                lambdaQueryWrapper.orderByAsc(orderBy);
            }else{
                lambdaQueryWrapper.orderByDesc(orderBy);
            }
        }
        return baseMapper.selectPage(page, lambdaQueryWrapper);
    }

    @Override
    public List<Orders> selectManualPage(Long lastId, Integer pageSize, OrdersVo state) {

        return baseMapper.selecManualPage(lastId, pageSize, state);
    }

    @Override
    public List<UserStaticsVo> staticsUser() {
        return baseMapper.staticsUser();
    }

    @Override
    public List<UserStaticsVo> staticsUserSingle() {
        return baseMapper.staticsUserSingle();
    }

    @Override
    public List<OffocialDemoVo> officialDemo(OrdersVo state) {
        return baseMapper.officialDemo(state);
    }
}